﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3.Admin
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        private dataDataContext dc = new dataDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            Employee us = (Employee)Session["user"];
            if (!IsPostBack)
            {
                if(us.RoleEmID==1)
                loaddata();
            }
        }

        protected void listView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
        {
            DataPager1.SetPageProperties(e.StartRowIndex, 5, false);
            loaddata();
        }

        protected void listView1_PagePropertiesChanged(object sender, EventArgs e)
        {

        }
        private void loaddata()
        {
            listView1.DataSource = dc.Customers.OrderByDescending(a => a.Status).ToList();
            listView1.DataBind();
        }
        protected void listView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
        {
            HiddenField hi = listView1.Items[e.NewSelectedIndex].FindControl("HiddenField1") as HiddenField;
            Response.Redirect("EditCustomer.aspx?id=" + hi.Value);
        }

        protected void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}